Imports System.Text
Public Class frmUserSecurity
    Inherits System.Windows.Forms.Form
    Dim Tuser As Integer = 0
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents chkFinanceAccounts As System.Windows.Forms.CheckBox
    Friend WithEvents dgFinanceAccounts As System.Windows.Forms.DataGrid
    Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents dgInventory As System.Windows.Forms.DataGrid
    Friend WithEvents chkInventory As System.Windows.Forms.CheckBox
    Friend WithEvents dgHRpayroll As System.Windows.Forms.DataGrid
    Friend WithEvents chkHRpayroll As System.Windows.Forms.CheckBox
    Friend WithEvents dgITadministration As System.Windows.Forms.DataGrid
    Friend WithEvents chkITadministration As System.Windows.Forms.CheckBox
    Friend WithEvents dgService As System.Windows.Forms.DataGrid
    Friend WithEvents chkService As System.Windows.Forms.CheckBox
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents cmbUser As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmbCompany As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmdSave As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents chkPOS As System.Windows.Forms.CheckBox
    Friend WithEvents dgPOS As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.dgFinanceAccounts = New System.Windows.Forms.DataGrid()
        Me.chkFinanceAccounts = New System.Windows.Forms.CheckBox()
        Me.GroupBox3 = New System.Windows.Forms.GroupBox()
        Me.cmdSave = New DevComponents.DotNetBar.ButtonX()
        Me.cmbCompany = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cmbUser = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.dgInventory = New System.Windows.Forms.DataGrid()
        Me.chkInventory = New System.Windows.Forms.CheckBox()
        Me.dgHRpayroll = New System.Windows.Forms.DataGrid()
        Me.chkHRpayroll = New System.Windows.Forms.CheckBox()
        Me.dgITadministration = New System.Windows.Forms.DataGrid()
        Me.chkITadministration = New System.Windows.Forms.CheckBox()
        Me.dgService = New System.Windows.Forms.DataGrid()
        Me.chkService = New System.Windows.Forms.CheckBox()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.chkPOS = New System.Windows.Forms.CheckBox()
        Me.dgPOS = New System.Windows.Forms.DataGrid()
        CType(Me.dgFinanceAccounts, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox3.SuspendLayout()
        CType(Me.dgInventory, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dgHRpayroll, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dgITadministration, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dgService, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        CType(Me.dgPOS, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'dgFinanceAccounts
        '
        Me.dgFinanceAccounts.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgFinanceAccounts.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgFinanceAccounts.CaptionVisible = False
        Me.dgFinanceAccounts.DataMember = ""
        Me.dgFinanceAccounts.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgFinanceAccounts.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgFinanceAccounts.Location = New System.Drawing.Point(9, 90)
        Me.dgFinanceAccounts.Name = "dgFinanceAccounts"
        Me.dgFinanceAccounts.RowHeadersVisible = False
        Me.dgFinanceAccounts.Size = New System.Drawing.Size(269, 401)
        Me.dgFinanceAccounts.TabIndex = 7
        '
        'chkFinanceAccounts
        '
        Me.chkFinanceAccounts.AutoSize = True
        Me.chkFinanceAccounts.BackColor = System.Drawing.Color.Transparent
        Me.chkFinanceAccounts.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkFinanceAccounts.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkFinanceAccounts.Location = New System.Drawing.Point(14, 66)
        Me.chkFinanceAccounts.Name = "chkFinanceAccounts"
        Me.chkFinanceAccounts.Size = New System.Drawing.Size(136, 22)
        Me.chkFinanceAccounts.TabIndex = 117
        Me.chkFinanceAccounts.Tag = "1"
        Me.chkFinanceAccounts.Text = "Finance/Accounts"
        Me.chkFinanceAccounts.UseVisualStyleBackColor = False
        '
        'GroupBox3
        '
        Me.GroupBox3.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox3.Controls.Add(Me.cmdSave)
        Me.GroupBox3.Controls.Add(Me.cmbCompany)
        Me.GroupBox3.Controls.Add(Me.cmdExit)
        Me.GroupBox3.Controls.Add(Me.cmbUser)
        Me.GroupBox3.Controls.Add(Me.Label2)
        Me.GroupBox3.Controls.Add(Me.Label1)
        Me.GroupBox3.Location = New System.Drawing.Point(8, -2)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(1111, 65)
        Me.GroupBox3.TabIndex = 146
        Me.GroupBox3.TabStop = False
        '
        'cmdSave
        '
        Me.cmdSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdSave.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdSave.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdSave.Location = New System.Drawing.Point(924, 22)
        Me.cmdSave.Name = "cmdSave"
        Me.cmdSave.Size = New System.Drawing.Size(82, 27)
        Me.cmdSave.TabIndex = 271
        Me.cmdSave.Text = "Save"
        '
        'cmbCompany
        '
        Me.cmbCompany.DisplayMember = "Text"
        Me.cmbCompany.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbCompany.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbCompany.ItemHeight = 19
        Me.cmbCompany.Location = New System.Drawing.Point(421, 22)
        Me.cmbCompany.Name = "cmbCompany"
        Me.cmbCompany.Size = New System.Drawing.Size(298, 25)
        Me.cmbCompany.TabIndex = 147
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(1015, 22)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 270
        Me.cmdExit.Text = "Exit"
        '
        'cmbUser
        '
        Me.cmbUser.DisplayMember = "Text"
        Me.cmbUser.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbUser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbUser.ItemHeight = 19
        Me.cmbUser.Location = New System.Drawing.Point(58, 22)
        Me.cmbUser.Name = "cmbUser"
        Me.cmbUser.Size = New System.Drawing.Size(267, 25)
        Me.cmbUser.TabIndex = 147
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(16, 23)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(36, 18)
        Me.Label2.TabIndex = 135
        Me.Label2.Text = "User"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(349, 23)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(66, 18)
        Me.Label1.TabIndex = 135
        Me.Label1.Text = "Company"
        '
        'dgInventory
        '
        Me.dgInventory.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgInventory.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgInventory.CaptionVisible = False
        Me.dgInventory.DataMember = ""
        Me.dgInventory.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgInventory.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgInventory.Location = New System.Drawing.Point(289, 90)
        Me.dgInventory.Name = "dgInventory"
        Me.dgInventory.RowHeadersVisible = False
        Me.dgInventory.Size = New System.Drawing.Size(269, 181)
        Me.dgInventory.TabIndex = 7
        '
        'chkInventory
        '
        Me.chkInventory.AutoSize = True
        Me.chkInventory.BackColor = System.Drawing.Color.Transparent
        Me.chkInventory.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkInventory.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkInventory.Location = New System.Drawing.Point(294, 66)
        Me.chkInventory.Name = "chkInventory"
        Me.chkInventory.Size = New System.Drawing.Size(87, 22)
        Me.chkInventory.TabIndex = 117
        Me.chkInventory.Tag = "2"
        Me.chkInventory.Text = "Inventory"
        Me.chkInventory.UseVisualStyleBackColor = False
        '
        'dgHRpayroll
        '
        Me.dgHRpayroll.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgHRpayroll.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgHRpayroll.CaptionVisible = False
        Me.dgHRpayroll.DataMember = ""
        Me.dgHRpayroll.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgHRpayroll.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgHRpayroll.Location = New System.Drawing.Point(570, 90)
        Me.dgHRpayroll.Name = "dgHRpayroll"
        Me.dgHRpayroll.RowHeadersVisible = False
        Me.dgHRpayroll.Size = New System.Drawing.Size(269, 181)
        Me.dgHRpayroll.TabIndex = 7
        '
        'chkHRpayroll
        '
        Me.chkHRpayroll.AutoSize = True
        Me.chkHRpayroll.BackColor = System.Drawing.Color.Transparent
        Me.chkHRpayroll.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkHRpayroll.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkHRpayroll.Location = New System.Drawing.Point(575, 66)
        Me.chkHRpayroll.Name = "chkHRpayroll"
        Me.chkHRpayroll.Size = New System.Drawing.Size(93, 22)
        Me.chkHRpayroll.TabIndex = 117
        Me.chkHRpayroll.Tag = "3"
        Me.chkHRpayroll.Text = "HR/Payroll"
        Me.chkHRpayroll.UseVisualStyleBackColor = False
        '
        'dgITadministration
        '
        Me.dgITadministration.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgITadministration.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgITadministration.CaptionVisible = False
        Me.dgITadministration.DataMember = ""
        Me.dgITadministration.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgITadministration.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgITadministration.Location = New System.Drawing.Point(289, 296)
        Me.dgITadministration.Name = "dgITadministration"
        Me.dgITadministration.RowHeadersVisible = False
        Me.dgITadministration.Size = New System.Drawing.Size(269, 195)
        Me.dgITadministration.TabIndex = 7
        '
        'chkITadministration
        '
        Me.chkITadministration.AutoSize = True
        Me.chkITadministration.BackColor = System.Drawing.Color.Transparent
        Me.chkITadministration.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkITadministration.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkITadministration.Location = New System.Drawing.Point(294, 274)
        Me.chkITadministration.Name = "chkITadministration"
        Me.chkITadministration.Size = New System.Drawing.Size(133, 22)
        Me.chkITadministration.TabIndex = 117
        Me.chkITadministration.Tag = "4"
        Me.chkITadministration.Text = "IT Administration"
        Me.chkITadministration.UseVisualStyleBackColor = False
        '
        'dgService
        '
        Me.dgService.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgService.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgService.CaptionVisible = False
        Me.dgService.DataMember = ""
        Me.dgService.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgService.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgService.Location = New System.Drawing.Point(570, 296)
        Me.dgService.Name = "dgService"
        Me.dgService.RowHeadersVisible = False
        Me.dgService.Size = New System.Drawing.Size(269, 195)
        Me.dgService.TabIndex = 7
        '
        'chkService
        '
        Me.chkService.AutoSize = True
        Me.chkService.BackColor = System.Drawing.Color.Transparent
        Me.chkService.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkService.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkService.Location = New System.Drawing.Point(575, 274)
        Me.chkService.Name = "chkService"
        Me.chkService.Size = New System.Drawing.Size(72, 22)
        Me.chkService.TabIndex = 117
        Me.chkService.Tag = "74"
        Me.chkService.Text = "Service"
        Me.chkService.UseVisualStyleBackColor = False
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.GroupBox3)
        Me.GroupPanel1.Controls.Add(Me.dgITadministration)
        Me.GroupPanel1.Controls.Add(Me.dgService)
        Me.GroupPanel1.Controls.Add(Me.chkITadministration)
        Me.GroupPanel1.Controls.Add(Me.dgFinanceAccounts)
        Me.GroupPanel1.Controls.Add(Me.chkService)
        Me.GroupPanel1.Controls.Add(Me.dgInventory)
        Me.GroupPanel1.Controls.Add(Me.chkPOS)
        Me.GroupPanel1.Controls.Add(Me.chkHRpayroll)
        Me.GroupPanel1.Controls.Add(Me.dgPOS)
        Me.GroupPanel1.Controls.Add(Me.dgHRpayroll)
        Me.GroupPanel1.Controls.Add(Me.chkInventory)
        Me.GroupPanel1.Controls.Add(Me.chkFinanceAccounts)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(1137, 597)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 147
        Me.GroupPanel1.Text = "User Security Roles"
        '
        'chkPOS
        '
        Me.chkPOS.AutoSize = True
        Me.chkPOS.BackColor = System.Drawing.Color.Transparent
        Me.chkPOS.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.chkPOS.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.chkPOS.Location = New System.Drawing.Point(855, 66)
        Me.chkPOS.Name = "chkPOS"
        Me.chkPOS.Size = New System.Drawing.Size(105, 22)
        Me.chkPOS.TabIndex = 117
        Me.chkPOS.Tag = "79"
        Me.chkPOS.Text = "Point of Sale"
        Me.chkPOS.UseVisualStyleBackColor = False
        '
        'dgPOS
        '
        Me.dgPOS.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgPOS.CaptionFont = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgPOS.CaptionVisible = False
        Me.dgPOS.DataMember = ""
        Me.dgPOS.Font = New System.Drawing.Font("Calibri", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.dgPOS.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgPOS.Location = New System.Drawing.Point(850, 90)
        Me.dgPOS.Name = "dgPOS"
        Me.dgPOS.RowHeadersVisible = False
        Me.dgPOS.Size = New System.Drawing.Size(269, 181)
        Me.dgPOS.TabIndex = 7
        '
        'frmUserSecurity
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(1137, 597)
        Me.ControlBox = False
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.Location = New System.Drawing.Point(50, 50)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmUserSecurity"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgFinanceAccounts, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox3.PerformLayout()
        CType(Me.dgInventory, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dgHRpayroll, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dgITadministration, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dgService, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        CType(Me.dgPOS, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub ICproducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim APdata As New APdataLogic
        Dim ds As DataSet
        ds = APdata.GetUserCompanies(EditUserID)
        cmbCompany.DataSource = ds.Tables(0)
        cmbCompany.ValueMember = "CompanyID"
        cmbCompany.DisplayMember = "CompanyName"
        cmbCompany.SelectedValue = CompanyID
        Dim ds2 As DataSet
        ds2 = APdata.GetUserList()
        cmbUser.DataSource = ds2.Tables(0)
        cmbUser.ValueMember = "USERID"
        cmbUser.DisplayMember = "USERNAME"

        Dim dr As SqlClient.SqlDataReader
        dr = APdata.LoadMainMenuGroups()
        While dr.Read
            If dr!MenuId = 1 Then
                chkFinanceAccounts.Checked = True
            ElseIf dr!MenuId = 2 Then
                chkInventory.Checked = True
            ElseIf dr!MenuId = 3 Then
                chkHRpayroll.Checked = True
            ElseIf dr!MenuId = 4 Then
                chkITadministration.Checked = True
            ElseIf dr!MenuId = 74 Then
                chkService.Checked = True
            ElseIf dr!MenuId = 79 Then
                chkPOS.Checked = True
            End If
        End While

        Call LoadOptions(EditUserID)

        Me.Location = New Point(5, 55)
        APdata = Nothing
    End Sub

    Private Sub LoadOptions(ByVal UID As Integer)
        Call LoadSecurityPrivileges(UID, 1, dgFinanceAccounts)
        Call LoadSecurityPrivileges(UID, 2, dgITadministration)
        Call LoadSecurityPrivileges(UID, 3, dgInventory)
        Call LoadSecurityPrivileges(UID, 4, dgHRpayroll)
        Call LoadSecurityPrivileges(UID, 5, dgService)
        Call LoadSecurityPrivileges(UID, 6, dgPOS)
    End Sub

    Private Sub LoadSecurityPrivileges(ByVal UID As Integer, ByVal MenuGroupId As Integer, ByVal dataGridId As DataGrid)
        Dim APdata As New APdataLogic
        Dim ds As DataSet
        ds = APdata.GetUserOptionPrompt(UID, MenuGroupId, cmbCompany.SelectedValue)
        dataGridId.DataSource = ds.Tables(0)
        APdata = Nothing
        With dataGridId
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With
        Dim cm As CurrencyManager = BindingContext(dataGridId.DataSource, dataGridId.DataMember)
        Dim dv As DataView = cm.List
        dv.AllowNew = False
        dgformat(dataGridId)
    End Sub

    Private Sub dgformat(ByVal dataGridId As DataGrid)
        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("calibri", 9.0!, FontStyle.Bold)
            .MappingName = "COMPANY"
            .PreferredColumnWidth = 140
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With
        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 0
        cs1.MappingName = "MENUID"
        cs1.HeaderText = "ID"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        Dim cs2 As DataGridBoolColumn
        cs2 = New DataGridBoolColumn
        cs2.Width = 28
        cs2.MappingName = "VALIDMENU"
        cs2.ReadOnly = False
        cs2.FalseValue = 0
        cs2.TrueValue = 1
        cs2.AllowNull = False
        grdTableStyle.GridColumnStyles.Add(cs2)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.MappingName = "MENUNAME"
        cs1.HeaderText = "OPTION NAME"
        cs1.Width = 230
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)

        dataGridId.TableStyles.Add(grdTableStyle)

    End Sub
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

        Try
            Call toDeleteExistingUserMenu()
            Call toSaveUserPrivileges(dgFinanceAccounts, 1, chkFinanceAccounts)
            Call toSaveUserPrivileges(dgITadministration, 2, chkITadministration)
            Call toSaveUserPrivileges(dgInventory, 3, chkInventory)
            Call toSaveUserPrivileges(dgHRpayroll, 4, chkHRpayroll)
            Call toSaveUserPrivileges(dgService, 74, chkService)
            Call toSaveUserPrivileges(dgPOS, 79, chkPOS)

            MsgBox("User Updated Successfully", 64, "Inventory Manager")

        Catch ex As Exception
            MsgBox(ex.ToString, 16, "Inventory Manager")
        End Try

    End Sub
    Sub toDeleteExistingUserMenu()
        Dim APdata As New APdataLogic
        APdata.toDeleteExistingUserMenu(EditUserID, cmbCompany.SelectedValue)
        APdata = Nothing
    End Sub
    Sub toSaveUserPrivileges(ByVal dataGridId As DataGrid, ByVal MenuId As Integer, ByVal checkBoxId As CheckBox)
        Try

            Dim InvXml As String
            Dim mrow As Integer
            Dim cm As CurrencyManager = BindingContext(dataGridId.DataSource, dataGridId.DataMember)
            Dim dv As DataView = cm.List
            mrow = dv.Count

            Dim sb As StringBuilder = New StringBuilder("")
            Dim n As Integer
            sb.Append("<InvoiceDetails>")
            sb.Append("<InvoiceData>")

            If checkBoxId.Checked = True Then

                sb.Append("<InvLine>")
                sb.Append("<MenuID>" & MenuId & "</MenuID>")
                sb.Append("</InvLine>")
                cm = BindingContext(dataGridId.DataSource, dataGridId.DataMember)
                dv = cm.List
                mrow = dv.Count
                For n = 0 To mrow - 1
                    If CStr(dataGridId.Item(n, 1)) = "True" Then
                        sb.Append("<InvLine>")
                        sb.Append("<MenuID>" + CStr(dataGridId.Item(n, 0)) + "</MenuID>")
                        sb.Append("</InvLine>")
                    End If
                Next

            End If

            sb.Append("</InvoiceData>")
            sb.Append("</InvoiceDetails>")
            InvXml = sb.ToString()

            Dim APdata As New APdataLogic
            APdata.UpdateUserProfile(EditUserID, cmbCompany.SelectedValue, InvXml)
            APdata = Nothing

        Catch ex As Exception
            MsgBox("Unable to Update user profile. Try later !", MsgBoxStyle.Critical, "Inventory Manager")
        End Try
    End Sub

    Private Sub dgFinanceAccounts_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgFinanceAccounts.MouseUp
        Call MouseUpofDataGrid(dgFinanceAccounts, e)
    End Sub

    Private Sub dgInventory_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgInventory.MouseUp
        Call MouseUpofDataGrid(dgInventory, e)
    End Sub
    Private Sub dgHRpayroll_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgHRpayroll.MouseUp, dgPOS.MouseUp
        Call MouseUpofDataGrid(dgHRpayroll, e)
    End Sub
    Private Sub dgITadministration_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgITadministration.MouseUp
        Call MouseUpofDataGrid(dgITadministration, e)
    End Sub
    Private Sub dgService_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgService.MouseUp
        Call MouseUpofDataGrid(dgService, e)
    End Sub
    Private Sub dgPOS_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgPOS.MouseUp
        Call MouseUpofDataGrid(dgPOS, e)
    End Sub

    Private Sub cmbUser_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbUser.SelectedIndexChanged, cmbCompany.SelectedIndexChanged
        If IsNumeric(cmbUser.SelectedValue) Then
            LoadOptions(cmbUser.SelectedValue)
        End If
    End Sub

    Private Sub cmbCompany_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbCompany.SelectedIndexChanged
        If IsNumeric(cmbCompany.SelectedValue) Then
            LoadOptions(cmbUser.SelectedValue)
        End If
    End Sub

    Private Sub chkFinanceAccounts_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkFinanceAccounts.CheckedChanged
        Call toCheckUncheckDataGrid(dgFinanceAccounts, chkFinanceAccounts)
    End Sub
    Private Sub chkInventory_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkInventory.CheckedChanged
        Call toCheckUncheckDataGrid(dgInventory, chkInventory)
    End Sub
    Private Sub chkITadministration_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkITadministration.CheckedChanged
        Call toCheckUncheckDataGrid(dgITadministration, chkITadministration)
    End Sub
    Private Sub chkHRpayroll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHRpayroll.CheckedChanged
        Call toCheckUncheckDataGrid(dgHRpayroll, chkHRpayroll)
    End Sub

    Private Sub chkService_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkService.CheckedChanged
        Call toCheckUncheckDataGrid(dgService, chkService)
    End Sub

    Private Sub chkPOS_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkPOS.CheckedChanged
        Call toCheckUncheckDataGrid(dgPOS, chkPOS)
    End Sub

    Sub toCheckUncheckDataGrid(ByVal dgId As DataGrid, ByVal cmbId As CheckBox)
        Dim mrow, drow As Integer
        Dim cm As CurrencyManager = BindingContext(dgId.DataSource, dgId.DataMember)
        Dim dv As DataView = cm.List
        mrow = dv.Count
        Dim n As Integer
        For n = 0 To mrow - 1
            If cmbId.Checked = True Then
                dgId.Item(n, 1) = True
            Else
                dgId.Item(n, 1) = False
            End If
        Next
    End Sub

    Sub MouseUpofDataGrid(ByVal dgId As DataGrid, ByVal e As MouseEventArgs)
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgId.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgId.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgId.Select(hti.Row)
            Dim CurrentRow As Integer = dgId.CurrentCell.RowNumber
            If dgId.Item(CurrentRow, 1) = True Then
                dgId.Item(CurrentRow, 1) = False
            Else
                dgId.Item(CurrentRow, 1) = True
            End If
        End If

    End Sub

   
    
End Class
